//
//  ViewController.m
//  UI08_页面间传值
//
//  Created by Scott on 16/3/18.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ViewController.h"
#import "VCOfSecond.h"

@interface ViewController ()

@property (nonatomic, retain) UITextField *textFieldOfUser;

@property (nonatomic, retain) UIButton *buttonOfNext;

@end

@implementation ViewController

- (void)dealloc {
    [_textFieldOfUser release];
    [_buttonOfNext release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"首页";
    
    [self createSubViews];
}


- (void)createSubViews {
    
    self.textFieldOfUser = [[UITextField alloc] initWithFrame:CGRectMake(20, 80, 300, 40)];
    self.textFieldOfUser.borderStyle = 3;
    self.textFieldOfUser.placeholder = @"请输入用户名";
    [self.view addSubview:self.textFieldOfUser];
    
    
    self.buttonOfNext = [UIButton buttonWithType:UIButtonTypeSystem];
    
    self.buttonOfNext.frame = CGRectMake(50, 200, self.view.frame.size.width - 100, 40);
    
    [self.buttonOfNext setTitle:@"Next" forState:UIControlStateNormal];
    
    [self.view addSubview:self.buttonOfNext];
    
    self.buttonOfNext.backgroundColor = [UIColor yellowColor];
    
    [self.buttonOfNext addTarget:self action:@selector(handleNext:) forControlEvents:UIControlEventTouchUpInside];
    
}

#pragma mark - 知识点1: 通过属性进行页面间传值.
- (void)handleNext:(UIButton *)button {
    
    VCOfSecond *second = [[VCOfSecond alloc] init];
    
    
    // 属性赋值
    second.content = self.textFieldOfUser.text;
    
    
    [self.navigationController pushViewController:second animated:YES];
    
    [second release];
    
}


#pragma mark - 知识点2: 通过delegate进行页面间传值.


#pragma mark -
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
